export function formatDate(type, value) {
  if (type === 'validityDate' || type === 'paymentDate' ||
      type === 'repaymentDate') {
    if (!value) return ''
    let date = new Date(value)
    let year = date.getFullYear()
    let month = date.getMonth() + 1
    month = month > 9 ? month : '0' + month
    let day = date.getDate()
    day = day > 9 ? day : '0' + day
    return year + '-' + month + '-' + day
  }
}

export function formatAddCardDate(type, value) {
  if (!value) return ''
  let date = new Date(value)
  let month = date.getMonth() + 1
  let day = date.getDate()
  let year = date.getFullYear()
  if(type === 'validityDate'){
    if(month < 10){
      month = '0' + month
    }
    return month + '/' + year.toString().substring(2, 4)
  }
  if(type === 'paymentDate' || type === 'repaymentDate'){
    if(day < 10){
      day = '0' + day
    }else {
      day = day.toString()
    }

    return day
  }
}